package test.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import test.annotation.AuthParam;
import test.domin.User;
import test.annotation.Whitelist;

import javax.servlet.http.HttpSession;
import java.util.UUID;

/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : example
 * @ Author: XuLeHuang
 * @ Date: 2022/6/24 16:51
 * @ Description:
 */
@Controller
@RequestMapping("/auth")
public class AuthValidateController {

    @RequestMapping("/toLoginPage")
    public String toLoginPage() {
        return "/login";
    }

    @RequestMapping("/doLoginPage")
    public String doLogin(HttpSession session) {
        User user = new User()
                .setId(UUID.randomUUID().toString())
                .setName("许乐煌")
                .setSex("男")
                .setAge(22)
                .setPerm("I");
        session.setAttribute("user" , user);
        return "/success";
    }

    @RequestMapping("/validate")
    public String authValidate(@AuthParam User user, HttpSession session) {
        System.out.println("执行authValidate方法");
        return "/auth";
    }

    @RequestMapping("/toAnonPage")
    public String toAnonPage() {
        return "/anon";
    }
}
